package com.kx.springboot.config;

import com.kx.springboot.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration  //定义此类为配置文件（相当于之前的xml文件）
public class InterceptorConfig implements WebMvcConfigurer {
    //mvc:interceptors
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] addPathPatterns = {
                "/user/**"
        };
        String[] excludePathPatterns = {
                "/user/login","/user/out","/user/error"
        };
        //mvc:interceptor bean class=""
        registry.addInterceptor(new UserInterceptor()).addPathPatterns(addPathPatterns).excludePathPatterns(excludePathPatterns);
//        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
